﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using laba2.Entity;
using laba2.Repository.IRepository;

namespace laba2.Repository.RepositoryImpl
{
    public class AchivementRepository: Repository<Achivement>, IAchivementRepository
    {
        public AchivementRepository(List<Achivement> list) : base(list)
        {
        }

        public List<Achivement> GetByStudent(Student student)
        {
            return (from achivement in _list
                    where achivement.Student == student
                    select achivement).ToList();
        }

        public List<Achivement> GetByCourse(Course course)
        {
            return (from achivement in _list
                    where achivement.Task.Course == course
                    select achivement).ToList();
        }

        public List<Achivement> GetByStudentAndCourse(Student student, Course course)
        {
            return (from achivement in _list
                    where achivement.Student == student && achivement.Task.Course == course select achivement).ToList();
        }

        public List<Achivement> GetByStudentId(int id)
        {
            return (from achivement in _list
                    where achivement.Student.Id == id 
                    select achivement).ToList();
        }

        public List<Achivement> GetByStudentIdAndCourseId(int studentId, int courseId)
        {
            return (from achivement in _list
                    where achivement.Student.Id == studentId && achivement.Task.Course.Id == courseId
                    select achivement).ToList();
        }
    }
}
